package com.things8.iot.baseIot.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.things8.iot.baseIot.entity.SysDevice;
import com.things8.iot.baseIot.entity.SysDeviceExample;
import com.things8.iot.baseIot.vo.DeviceVo1;
import com.things8.iot.baseIot.dto.QueryDeviceDto;
import com.things8.iot.common.utils.PageUtil;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.things8.iot.baseIot.dao.SysDeviceMapper;

import java.util.List;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/5/2 21:24
 */
@Service
public class SysDeviceService {

    @Resource
    private SysDeviceMapper sysDeviceMapper;

    public List<SysDevice> queryBySysId(Long sysId) {
        SysDeviceExample example = new SysDeviceExample();
        example.createCriteria().andSerialnumberLike("8");
        return sysDeviceMapper.selectByExample(example);
    }

    public IPage<DeviceVo1> pageList(QueryDeviceDto queryDeviceDto) {
        return sysDeviceMapper.findAllByNameLike(PageUtil.getObjectPage(queryDeviceDto), queryDeviceDto.getSearchContent());
    }


    @Async("taskExecutor")
    public void async() {
        long l = System.currentTimeMillis();

        int a = 0;
        for (int i = 0; i < 9999999; i++) {
            a++;
         /*   if (i % 2 == 0) {
                System.out.println(Thread.currentThread().getName() + "========>" + i);
            }*/
        }
        System.out.println(Thread.currentThread().getName() + "========执行次数==========>" + a);

        System.out.println(Thread.currentThread().getName() + "================执行时间=================>" + (System.currentTimeMillis() - l));

    }

}

